<template>
	<view>
		<view class="middle">
			<view class="middle_top">
				<view>拍照上传</view>
			</view>
			<view class="middle_box">
				<view class="uploada" @click="huidanaddImagea()">
					<!-- <image src="../../static/iocn37.png" v-if="src == 'https://syh-1.oss-cn-shanghai.aliyuncs.com/' || src == 'https://syh-1.oss-cn-shanghai.aliyuncs.com/undefined'">
						</image> -->
					<image :src="src"></image>
				</view>
			</view>
		</view>
		<view class="container">
			<view class="container_top">
				<view>快递寄回</view>
			</view>
			<view class="container_box">
				<view>
					<text>*</text>
					<text>快递单号</text>
					<input type="text" v-model="waybill" placeholder="请输入快递单号" />
				</view>
			</view>
			<view class="container_top">
				<view>回单状态</view>
			</view>
			<view class="container_xuanze">
				<view class="chek">
					<uni-data-checkbox v-model="radio1" selectedColor="#EF4D3D" :localdata="zhuangtai">
					</uni-data-checkbox>
				</view>

			</view>
		</view>
		<view class="footer">
			<view class="footer_fr" @click="CreateReceiptBill()">确定</view>
		</view>
		<view v-show="jiazaizhong" class="view_nav">
			<u-loading-icon></u-loading-icon>
		</view>

	</view>
</template>

<script>
	import {
		CreateReceiptBill

	} from '@/public/Api/update.js'
	import {
		setValue,
		getValue
	} from '@/public/storeage/index.js'
	export default {
		data() {
			return {
				radio1: 0,
				waybill: '',
				zhuangtai: [{
					text: '发出回单',
					value: 0
				}, {
					text: '客户签收',
					value: 1,
					// 禁用当前项
					"disable": true

				}, {
					text: '异常终止',
					value: 2,
					// 禁用当前项
					"disable": true
				}],

				src: '', // 上传身份证 -- 国徽面
				wayid: '',
				jiazaizhong: false
			};
		},
		onLoad(option) {
			// var mobile = getValue('mobile')
			// var statusact = getValue('statusact')
			// if (statusact == '停用') {
			// 	uni.reLaunch({
			// 		url: '/pages/Loginas/index'
			// 	})
			// }
			this.wayid = option.id

		},

		methods: {
			// 上传身份证 -- 国徽面
			huidanaddImagea() {
				var that = this;
				// let token = getValue('token')
				console.log(123)
				// 从本地相册选择图片或使用相机拍照。
				uni.chooseImage({
					count: 10, //最多可以选择的图片张数，默认9
					//album 从相册选图，camera 使用相机，默认二者都有。
					sourceType: ['album'],
					success: function(res) {
						//获取图片信息。
						uni.getImageInfo({
							src: res.tempFilePaths[0],
							success: function(image) {
								that.jiazaizhong = true
								// that.src = (res.tempFilePaths[0]);
								// console.log(that.src); //打印出图片信息,在浏览器上打开就是你上传的图片
								//将本地资源上传到开发者服务器，客户端发起一个 POST 请求，其中 content-type 为 multipart/form-data
								uni.uploadFile({
									//开发者服务器 url
									url: 'https://api.syh56.com:21026/api/UploadOSS',
									//获取要上传文件资源的路径。
									// filePath: res.tempFilePaths[0],
									filePath: res.tempFilePaths[0],
									//文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
									name: 'files',
									//HTTP 请求 Header, header 中不能设置 Referer。
									header: {
										'Abp.TenantId': '1',
										'content-type': 'multipart/form-data'
									},
									//成功的回调fullurl
									success: uploadFileRes => {
										console.log(uploadFileRes)
										//获取图片信息 网站域名 + res1.data.url就是一个图片的完整路径了
										var res1 = JSON.parse(uploadFileRes.data);
										uni.setStorageSync('sjhd', res1
											.result); //身份证国徽
										that.src = (res.tempFilePaths[0]);
										that.jiazaizhong = false
									}
								})
							}
						})
					}
				})
			},
			change(e) {
				this.value = e
			},


			async CreateReceiptBill() {
				var id = getValue('id')
				var courierNumber = this.waybill
				var courierType = '顺丰'
				var waybillId = this.wayid
				var photo1 = getValue('sjhd')
				var status = 1
				try {
					const {
						data: res
					} = await CreateReceiptBill({
						id,
						courierNumber,
						courierType,
						waybillId,
						photo1,
						status
					})
					console.log(res)
					uni.showToast({
						title: "提交成功",
						icon: 'none',
					})
					// setTimeout(function() {
					// 	uni.reLaunch({
					// 		url: '/pages/PersonalCenter/sjindex'
					// 	})
					// }, 600)
				} catch (e) {}
			},

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
		padding: 0 15upx;
	}

	.boxt_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 25upx;
		background-color: #fff;
		margin-top: 20upx;
	}

	.content {
		margin-top: 20upx;
		border-radius: 17.52upx;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #cccccc, 1.75upx 1.75upx 7.01upx 0px #cccccc;
		padding: 0 25upx;
		background-color: #fff;

		view {
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			height: 80upx;
			border-bottom: 1upx solid #e5e5e5;
			font-size: 32upx;
			font-weight: bold;
			padding: 0 15upx;

			text {
				// color: #EF4D3D;
				// padding-right: 10upx;
			}
		}

		input {
			display: block;
			font-size: 25upx;
			text-align: right;
			width: 450upx;
			font-weight: 400;
		}
	}

	.middle {
		margin-top: 20upx;
		border-radius: 17.52upx;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #cccccc, 1.75upx 1.75upx 7.01upx 0px #cccccc;
		padding: 30upx 25upx;
		background-color: #fff;

		.middle_top {
			padding-bottom: 30upx;
			border-bottom: 2upx solid #e5e5e5;

			view {
				width: 130upx;
				line-height: 54upx;
				border-radius: 10upx;
				background-color: #EF4D3D;
				text-align: center;
				line-height: 54upx;
				color: #fff;
				font-weight: bold;
				font-size: 26upx;
				font-weight: bold;
			}
		}

		.middle_key {
			display: flex;
			align-items: center;
			font-size: 32upx;
			font-weight: bold;
			padding-top: 25upx;

			text {
				color: #EF4D3D;
				padding-right: 10upx;
			}
		}

		.middle_box {

			display: flex;
			align-items: center;
			margin: 0 auto;
			margin-top: 38upx;
			width: 405upx;
			height: 338upx;

			.uploada {
				// border: 1px solid red;
				background: url('@/static/iocn48.jpg') no-repeat;
				background-size: 380upx 220upx;
                height: 262upx;
			}

			image {
				width: 380upx;
				height: 230upx;

			}
		}
	}

	.container {
		margin-top: 20upx;
		border-radius: 17.52upx;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #cccccc, 1.75upx 1.75upx 7.01upx 0px #cccccc;
		padding: 0 25upx;
		background-color: #fff;

		.container_top {
			padding: 30upx 0;

			view {
				width: 130upx;
				line-height: 54upx;
				border-radius: 10upx;
				background-color: #EF4D3D;
				text-align: center;
				line-height: 54upx;
				color: #fff;
				font-weight: bold;
				font-size: 26upx;
				font-weight: bold;
			}
		}

		.container_box {
			view {
				display: flex;
				align-items: center;
				justify-content: space-between;
				height: 90upx;
				border-bottom: 2upx solid #e5e5e5;

				text:nth-child(1) {
					color: #EF4D3D;
					position: absolute;
					margin-left: 20upx;
				}

				text {
					font-size: 28upx;
					font-weight: bold;
					margin-left: 40upx;
				}

				input {
					width: 400upx;
					height: 70upx;
					font-size: 24upx;
					text-align: center;
					border: 1px solid #e5e5e5;
					background-color: rgba(229, 229, 229, 1);
					margin-right: 60upx;
				}
			}
		}
	}

	.container_xuanze {
		.chek {

			padding-bottom: 60upx;
			padding-top: 30upx;
			padding-left: 30upx;
		}
	}

	.primary {
		padding-top: 140upx;
		padding-bottom: 50upx;

		.primary_top {
			font-size: 24upx;
			text-align: center;
			color: #383838;
			line-height: 40upx;
		}

		.primary_key {
			display: flex;
			align-items: center;
			justify-content: center;
			padding-top: 30upx;

			image {
				width: 28upx;
				height: 28upx;
			}

			text {
				font-size: 24upx;
				font-weight: bold;
				padding-left: 25upx;
			}
		}

		.primary_box {
			width: 436upx;
			height: 72upx;
			border-radius: 20upx;
			text-align: center;
			line-height: 72upx;
			background-color: #EF4D3D;
			font-size: 38upx;
			color: #fff;
			font-weight: bold;
			margin: 0 auto;
			margin-top: 45upx;
		}
	}



	.footer {
		width: 750upx;
		opacity: 1;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 30upx 35upx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.footer_fl {
			.box_top {
				font-size: 28upx;
				color: #F04D3E;
				font-weight: bold;
				display: block;
				text-align: right;
			}

			.box_box {
				font-size: 22.78upx;
				color: #000;
				text-align: right;
				display: block;
			}
		}


		.footer_fr {
			width: 451upx;
			height: 70upx;
			opacity: 1;
			border-radius: 17.52upx;
			background: #EF4D3D;
			font-size: 31.54upx;
			color: #fff;
			text-align: center;
			line-height: 66upx;
			font-weight: bold;
			margin: 0 auto;
		}
	}

	.view_nav {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.6);
		z-index: 9999;
		// v-show="jiazaizhong"
		display: flex;
		align-items: center;
		justify-content: center;
		// view{
		// 	display: flex;
		// 	align-items: center;
		// 	justify-content: center;
		// 	position: absolute;
		// 	top: 50%;
		// 	left: 50%;
		// 	transform: translate(-50%, -50%);
		// }
	}
</style>
